package com.ruoyi.lowcode.sqlgenerator;


import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.lowcode.domain.LcField;
import com.ruoyi.lowcode.domain.LcModel;
import com.ruoyi.lowcode.domain.bo.ModelRowBo;
import com.ruoyi.lowcode.domain.bo.SelectListModelBo;
import com.ruoyi.lowcode.domain.vo.LcDatabaseSourceVo;
import com.ruoyi.lowcode.domain.vo.LcFieldVo;
import net.sf.jsqlparser.JSQLParserException;

import java.util.List;
import java.util.Map;

public interface GeneratorFactory {

    /**
     * 新增
     *
     * @param databaseSource
     * @param fieldList
     * @param modelRowBo
     * @param tableIds
     * @return
     */
    List<String> insert(LcDatabaseSourceVo databaseSource, List<LcFieldVo> fieldList, ModelRowBo modelRowBo, Map<String, String> tableIds);

    /**
     * 修改
     *
     * @param databaseSource
     * @param fieldList
     * @param modelRowBo
     * @param tableIds
     * @return
     */
    List<String> update(LcDatabaseSourceVo databaseSource, List<LcFieldVo> fieldList, ModelRowBo modelRowBo, Map<String, String> tableIds);

    /**
     * 删除
     *
     * @param tableName
     * @param fieldName
     * @param fieldValue
     * @return
     */
    String delete(String tableName, String fieldName, Object fieldValue);

    /**
     * 分页
     *
     * @param pageQuery
     * @return
     */
    String paging(PageQuery pageQuery);

    /**
     * 构建sql查询条件
     *
     * @param selectListModelBo
     * @param model
     * @return
     */
    String conditionalSql(SelectListModelBo selectListModelBo, LcModel model, List<LcField> fieldList) throws JSQLParserException;

    /**
     * 构建查询字段
     *
     * @param queryFieldList
     * @return
     */
    String getSelectFieldSql(List<LcFieldVo> queryFieldList);

    /**
     * 获取查询sql
     *
     * @param selectSql
     * @return
     */
    String getSelectWhereSql(String selectSql);

    /**
     * 构建统计字段
     *
     * @param field
     * @param type
     * @return/
     */
    String getCountFieldSql(String field, int type);

}
